<template>
    <div class="distributionProperties-view">
        <el-dialog title="分配楼盘" :visible.sync="dialogFormVisible" :show-close="showimg"  :close-on-click-modal="showimg">
        <div>
            <div class="cotent-botton">
                <div class="cotent-botton-input">
                    <el-input
                            placeholder="楼盘名称"
                            v-model="value1"
                            clearable>
                    </el-input>
                </div>
                <div class="cotent-botton-input">
                    <el-select v-model="value2"   @change="getprovince" value-key="id" clearable placeholder="请选择省">
                        <el-option
                                v-for="item in citylist"
                                :key="item.id"
                                :label="item.name"
                                :value="item"
                               >
                        </el-option>
                    </el-select>
                </div>
                <div class="cotent-botton-input">
                    <el-select v-model="value3" @change="getcitymsg" value-key="id"  placeholder="请选择城市">
                        <el-option
                                v-for="item in citylist1"
                                :key="item.id"
                                :label="item.name"
                                :value="item">
                        </el-option>
                    </el-select>
                </div>
                <div class="cotent-botton-input">
                    <el-select v-model="value4" value-key="id"  placeholder="请选择城区">
                        <el-option
                                v-for="item in citylist2"
                                :key="item.id"
                                :label="item.name"
                                :value="item">
                        </el-option>
                    </el-select>
                </div>
                <div class="cotent-botton-input">
                    <el-select v-model="value5"  placeholder="是否上架">
                        <el-option
                                v-for="item in options1"
                                :key="item.value"
                                :label="item.label"
                                :value="item.value">
                        </el-option>
                    </el-select>
                </div>
                <div class="cotent-botton-botton-one"  @click="queryInfo">查 询</div>
                <div class="cotent-botton-botton-two" @click="emptyingInfo">清 空</div>
            </div>
        </div>

            <linkerList :headlist="headlist" :contentlist="list" @selectList="selectList"></linkerList>
            <Pagination :totalpag="totalpag" v-on:currentpage="currentpage"></Pagination>
            <div slot="footer" class="dialog-footer">
                <el-button class="cancel-button" @click="closeForm">取 消</el-button>
                <el-button class="sure-button" type="primary" @click="preservation">保 存</el-button>
            </div>
        </el-dialog>
    </div>
</template>

<script>
    var AV = require('leancloud-storage');
    import linkerList from '../user/linkerList';
    import Pagination from '../Pagination';

    export default {
        name: "distributionProperties",
        data(){
            return{
                showimg:false,
                organizationId: this.$store.getters.userData.userMsg.id,//组织id
                organizationIdlists:"",
                // dialogFormVisible: false,
                value1:"",
                value2:"",
                value3:"",
                value4:"",
                value5:"",
                options1:[{
                    value: '0',
                    label: '已上架'
                },{
                    value: '1',
                    label: '已下架'
                }],
                selectLists:"",
                headlist:{
                    checkout:true,
                    operation:{
                        type:false,
                        fromurl:"",
                    },
                    list:[
                        {
                            prop:"id",
                            label:"序号",
                            width:"80",
                        },{
                            prop:"houseName",
                            label:"名称",
                            width:"150",
                        },{
                            prop:"houseType",
                            label:"分类",
                            width:"80",
                        }
                        ,{
                            prop:"address",
                            label:"所在地",
                            width:"240",
                        }
                        ,{
                            prop:"price",
                            label:"价格",
                            width:"80",
                        }
                        ,{
                            prop:"propertyType",
                            label:"物业类型",
                            width:"110",
                        }
                        ,{
                            prop:"shelfFlag",
                            label:"上架状态",
                            width:"110",
                        }
                    ]},
                list:[],
                totalpag:0,
                current:1,
                citylist: [],
                citylist1:[],
                citylist2:[],
                value4: '',
                value5: '',
            }
        },
        props:{
            dialogFormVisible:{
                type:Boolean,
            },
            organizationIds:{
                type: String
            },
        },
        components: {
            linkerList,
            Pagination,
        },
        watch: {
            organizationIds:{
                handler(newValue, oldValue) {
                    this.organizationIdlists=newValue
                    console.log(newValue,"xxxxxxxxxxxxxxxxxxxxxxxx")
                }
            }
            // dialogFormVisible:{
            //     handler(newValue, oldValue) {
            //         this.dialogFormVisible=newValue
            //     }
            // }
            // value2(){
            //   console.log(this.value2,"}}}}}}}}}}")
            //     this.value3=""
            //     if(this.value2){
            //         let _this = this;
            //         let params={
            //             pid:this.value2,
            //         }
            //         _this.Api.setting.cityList(params).then((data)=>{
            //             console.log("kkkkkkkkkkkkkkkkkkk",data)
            //             _this.citylist1=data.data;
            //         })
            //     }
            //
            // },
            // value3(){
            //     console.log(this.value3,"}}}}}}}}}}")
            //     this.value4=""
            //     if(this.value3){
            //         let _this = this;
            //         let params={
            //             pid:this.value3,
            //         }
            //         _this.Api.setting.cityList(params).then((data)=>{
            //             console.log("kkkkkkkkkkkkkkkkkkk",data)
            //             _this.citylist2=data.data;
            //         })
            //     }
            //
            // },
        },
        mounted(){
            this.getlist()
            this.getcity()
        },
        methods:{
            closeForm() {
                this.$emit("close");
            },
            getcity(){
                let _this = this;
                let params={
                    pid:0,
                }
                _this.Api.setting.cityList(params).then((data)=>{
                    console.log("kkkkkkkkkkkkkkkkkkk",data)
                    _this.citylist=data.data;
                })
            },
            //查看省
            getprovince(event){
                this.value3=""
                this.value4=""
                this.citylist2=[]
                if(event){
                    let _this = this;
                    let params={
                        pid:event.id,
                    }
                    _this.Api.setting.cityList(params).then((data)=>{
                        console.log("kkkkkkkkkkkkkkkkkkk",data)
                        _this.citylist1=data.data;
                    })
                }
                console.log("省省省省省省省省省省省省省省省省省省",event)
            },
            getcitymsg(event){
                this.value4=""
                    if(event){
                        let _this = this;
                        let params={
                            pid:event.id,
                        }
                        _this.Api.setting.cityList(params).then((data)=>{
                            console.log("kkkkkkkkkkkkkkkkkkk",data)
                            _this.citylist2=data.data;
                        })
                    }
                console.log("事实上司",event)
            },
            selectList(val){
                this.selectLists=val
                console.log(val)
            },
            //保存
            preservation(){
                let _this = this;
                let params={
                    structId:this.organizationIdlists,
                    houseIds:this.selectLists,
                }
                _this.Api.setting.divideHouses(params).then((data)=>{
                    if(data.returnCode==10000){
                        this.$message({
                            message: '添加楼盘成功',
                            type: 'success'
                        });
                        this.dialogFormVisible = false
                    }else {
                        this.$message({
                            message: data.msg,
                            type: 'warning'
                        });
                    }

                }).catch(() => {
                    this.$message({
                        message: '添加楼盘失败',
                        type: 'warning'
                    });
                    this.dialogFormVisible = false
                });
            },
            //查询
            queryInfo(){
                if (this.value1==""&&this.value2==""&&this.value3==""&&this.value4==""&&this.value5=="") {
                    this.$message({
                        message: '没有输入或选择查询内容',
                        type: 'warning'
                    });
                }else {
                    this.getlist()
                }
            },
            //清空
            emptyingInfo(){
                this.value1="";
                this.value2="";
                this.value3="";
                this.value4="";
                this.value5="";
                this.getlist();
            },
            currentpage(currentpage){
                console.log("当前页，",currentpage)
                this.current=currentpage
                this.getlist()
            },

            getlist(){
                let _this = this;
                let params={
                    current:_this.current,
                    size:10,
                    distributorId:this.organizationId,
                    houseName: this.value1,
                    province: this.value2.name,
                    city: this.value3.name,
                    area: this.value4.name,
                    shelfFlag:this.value5,
                }
                _this.Api.setting.queryHouses(params).then((data)=>{
                    _this.totalpag=data.data.total?data.data.total:0;
                    _this.list=data.data.records?data.data.records:[];
                })
            }
        }
    }
</script>
<style>
   .distributionProperties-view  .el-dialog--small {
        width:942px;
        top: 3%!important;
    }
   .distributionProperties-view .el-form-item__label {
        text-align: right;
        vertical-align: middle;
        float: left;
        font-size: 14px;
        font-family:PingFangSC-Regular;
        font-weight:400;
        color:rgba(0,0,0,0.85);
        line-height:22px;
        padding: 7px 0px 0px 30px;
        box-sizing: border-box;
    }
   .distributionProperties-view  .el-dialog__header{
        height: 50px;
        padding: 10px ;
        text-align: left;
        font-size:16px;
        font-family:PingFangSC-Medium;
        font-weight:500;
        color:rgba(0,0,0,0.85);
        line-height:24px;

    }
   .distributionProperties-view .el-dialog__body{
        border-top: 1px #E9E9E9 solid;
        border-bottom: 1px #E9E9E9 solid;
    }
   .distributionProperties-view .el-table .cell{
        text-align: left;
    }

</style>
<style  scoped rel="stylesheet/scss" lang="scss">
    .cotent-botton{
        display: flex;
        margin-bottom: 24px;
    .cotent-botton-input{
        width:150px;
        height:32px;
        margin-right: 16px;

    }
    .cotent-botton-botton-one{
        width:65px;
        height:32px;
        line-height: 32px;
        text-align: center;
        background:rgba(24,144,255,1);
        border-radius:4px;
        font-size:14px;
        font-family:PingFangSC-Regular;
        font-weight:400;
        color:rgba(255,255,255,1);
        margin-right: 16px;
    }
    .cotent-botton-botton-two{
        width:65px;
        height:32px;
        line-height: 32px;
        background:rgba(255,255,255,1);
        border-radius:4px;
        border:1px #D9D9D9 solid;
        font-size:14px;
        font-family:PingFangSC-Regular;
        font-weight:400;
        color:rgba(0,0,0,0.65);
        text-align: center;
        margin-right: 16px;
    }
    .cotent-botton-botton-two2{
        width:88px;
        height:32px;
        line-height: 32px;
        background:rgba(255,255,255,1);
        border-radius:4px;
        border:1px #D9D9D9 solid;
        font-size:14px;
        font-family:PingFangSC-Regular;
        font-weight:400;
        color:rgba(0,0,0,0.65);
        text-align: center;
        margin-right: 16px;
    }
    }
    .cancel-button{
        padding: 0px;
        width:78px;
        height:32px;
        line-height:32px;
        border-radius:4px;
        border:1px #D9D9D9 solid;
        font-size:14px;
        font-family:PingFangSC-Regular;
        font-weight:400;
        color:rgba(0,0,0,0.25);
        text-align: center;
    }
    .sure-button{
        padding: 0px;
        width:78px;
        height:32px;
        line-height:32px;
        border-radius:4px;
        background:rgba(24,144,255,1);
        font-size:14px;
        font-family:PingFangSC-Regular;
        font-weight:400;
        color:rgba(255,255,255,1);
        text-align: center;
    }
</style>